package cn.village.service.impl;
import cn.village.dao.IncomeAndExpenditureMapper;
import cn.village.entity.IncomeAndExpenditure;
import cn.village.service.IncomeAndExpenditureService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class IncomeAndExpenditureServiceImpl implements IncomeAndExpenditureService {

    @Resource
    private IncomeAndExpenditureMapper incomeAndExpenditureMapper;

    public IncomeAndExpenditure getIncomeAndExpenditureById(String id)throws Exception{
        return incomeAndExpenditureMapper.getIncomeAndExpenditureById(id);
    }

    public List<IncomeAndExpenditure>	getIncomeAndExpenditureListByMap(Map<String,Object> param)throws Exception{
        return incomeAndExpenditureMapper.getIncomeAndExpenditureListByMap(param);
    }

    public Integer getIncomeAndExpenditureCountByMap(Map<String,Object> param)throws Exception{
        return incomeAndExpenditureMapper.getIncomeAndExpenditureCountByMap(param);
    }

    public Integer qdtxAddIncomeAndExpenditure(IncomeAndExpenditure incomeAndExpenditure)throws Exception{
            //incomeAndExpenditure.setCreatedTime(new Date());
            return incomeAndExpenditureMapper.insertIncomeAndExpenditure(incomeAndExpenditure);
    }

    public Integer qdtxModifyIncomeAndExpenditure(IncomeAndExpenditure incomeAndExpenditure)throws Exception{
        //incomeAndExpenditure.setUpdatedTime(new Date());
        return incomeAndExpenditureMapper.updateIncomeAndExpenditure(incomeAndExpenditure);
    }

    public Integer qdtxDeleteIncomeAndExpenditureById(String id)throws Exception{
        return incomeAndExpenditureMapper.deleteIncomeAndExpenditureById(id);
    }

    public Integer qdtxBatchDeleteIncomeAndExpenditure(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return incomeAndExpenditureMapper.batchDeleteIncomeAndExpenditure(param);
    }


}
